package com.oig.sys.workflow.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

@Schema
@Data
public class DataModuleDto {

	@Schema(description = "ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "参数错误,规则id不能为空", groups= {GroupEdit.class})
	private Integer id;
	@Schema(description = "实体对象名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,实体对象名称不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String name;
	@Schema(description = "实体对象表名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,实体对象表名不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String tableName;

	@Schema(description = "备注说明")
	private String remark;

	@Schema(description = "实体对象JSON", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "实体对象JSON必填", groups={GroupAdd.class, GroupEdit.class})
	private String dataJson;

	@Schema(description = "实体对象列列表", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "实体对象列必填", groups={GroupAdd.class, GroupEdit.class})
	@Size(min = 1,message = "至少实体对象列", groups={GroupAdd.class, GroupEdit.class})
	@Valid
	private List<DataModuleDetailDto> dataModuleDetailDtoList;

	@Hidden
	@Schema(description = "最后更新人id")
	private Integer lastUpdateId;
	@Hidden
	@Schema(description = "最后更新人")
	private String lastUpdateName;
	@Hidden
	@Schema(description = "最后更新时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastUpdateTime;
}
